#!/usr/bin/lua
require "apm_core"

local G_DEBUG = false

if G_DEBUG == false then
    function logDebug(fmt,...) end
    function logInfo(fmt,...) end
    function logWarn(fmt,...) end
    function logError(fmt,...) end
    function logFatal(fmt,...) end
end

local arr_channels = {
    {"EBNK", "网上银行"},
    {"AUTO", "自助终端"},
    {"ATMP", "ATM"},
    {"POSP", "POS"},
    {"TBNK", "电话银行"}
}

-- return 1: 该数据不上报;其它:上报数据
function post_analysis()
    local ApmData = require("ApmData")
    if ApmData.getL7Proto() ~= 1414 then return end

    local s_em_type = ApmData.getMsgType()
    if s_em_type == nil then
        return
    end

    logInfo("test for cnaps2")

    local i_channel_index =  os.time() % #arr_channels + 1
    local s_channel_code = arr_channels[i_channel_index][1]
    local s_channel_name = arr_channels[i_channel_index][2]

    ApmData.replaceField("transaction.channel_name", s_channel_name)
    ApmData.replaceField("transaction.channel_code", s_channel_code)

    return
end
